package com.xiaobias.myInstanceof;

public class TestInstanceof {
    public static void main(String[] args) {
        before();
        after();
    }
    private static void before() {
        Object o = 1;
        if (o instanceof Integer) {
            Integer i = (Integer) o;
            System.out.println(i.intValue());
        } else if (o instanceof String) {
            String s = (String) o;
            System.out.println(s.charAt(0));
        }
    }

    private static void after() {
        Object o = 1;
        if (o instanceof Integer i) {
            System.out.println(i.intValue());
        } else if (o instanceof String s) {
            System.out.println(s.charAt(0));
        }
    }
}
